package com.sample.library.util

/**
 * @author  ddnosh
 * @website http://blog.csdn.net/ddnosh
 */
object StringUtil {
    /**
     * return if str is empty
     *
     * @param str
     * @return
     */
    @JvmStatic
    fun isEmpty(str: String?): Boolean {
        return str == null || str.length == 0 || str.equals("null", ignoreCase = true) || str.isEmpty() || str == ""
    }

    @JvmStatic
    fun getTrimedString(s: String): String {
        return trim(s)
    }

    @JvmStatic
    fun trim(s: String?): String {
        return s?.trim { it <= ' ' } ?: ""
    }

    @JvmStatic
    fun equals(str1: String, str2: String): Boolean {
        return str1 === str2 || equalsNotNull(str1, str2)
    }

    @JvmStatic
    fun equalsNotNull(str1: String?, str2: String): Boolean {
        return str1 != null && str1 == str2
    }

    @JvmStatic
    fun isBlank(str: String?): Boolean {
        return str == null || str.trim { it <= ' ' }.length == 0
    }

}
